#include <stdio.h>
#include <stdbool.h>
#include <ctype.h>
#include <stdlib.h>
#include <time.h>
int roll_dice(void);
bool play_game(void);
int main(void)
{
    srand((unsigned) time(NULL));
    int win = 0, loss = 0;
    char again;
    do {
        if (play_game()) {
            win++;
            printf("You win!\n");
        }
        else {
            loss++;
            printf("You lose!\n");
        }
        printf("Pay again? ");
        scanf(" %c", &again);
    } while (again == 'y' || again == 'Y');
    printf("Wins: %d, Losses: %d\n", win, loss);
    return 0;
}
int roll_dice(void) {
    int r1, r2;
    r1 = rand() % 6 + 1;
    r2 = rand() % 6 + 1;
    return r1 + r2;
}
bool play_game(void) {
    int point = 0, rolled;
    for (;;) {
        rolled = roll_dice();
        printf("You rolled: %d\n", rolled);
        if (point == 0) {
            switch (rolled)
            {
            case 7: case 11:
                return true;
            case 2: case 3: case 12:
                return false;
            default:
                point = rolled;
                printf("Your point is %d\n", point);
                break;
            }
        } else {
            if (rolled == point) {
                return true;
            } else if (rolled == 7) {
                return false;
            }
        }
    }
}